package day017.File;

import day015.map.HashMapTest;

import java.io.File;
import java.util.HashMap;

public class FileTest2 {
    public static void main(String[] args) {
        File file = new File("day17_demo\\统计文件个数文件夹");
        getFileCount(file);
    }

    public static void getFileCount(File f) {
        HashMap<String, Integer> hm = new HashMap<>();

        if (f.isDirectory()) {
            File[] files = f.listFiles();

            for (File file : files) {
                String fileName = file.getName();
                String name = fileName.split("\\.")[1];
                if (hm.containsKey(name)) {
                    hm.put(name, hm.get(name) + 1);
                } else {
                    hm.put(name, 1);
                }
            }
        }
        System.out.println(hm);
    }
}
